/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sd.rmi.auction.client;

/**
 *
 * @author blackdevil
 */
public class Client {

    public static void main(String arg[])
    {
        int retry= 5;
        int step = 1;
        String service = "auction";
        String product;
        try
        {
            System.out.println("Client init");
            ClientProxy client = new ClientProxy( service);
            System.out.println("Retrieve product name");
            product=client.getProduct();
            System.out.println("Product name: " + product);
            System.out.println("Retrieve current bid");
            int currPrice = client.getCurrentBid();
            System.out.println("Current product price is" + currPrice);
            System.out.println("Try to buy: Retry number" + retry + "Step: " + step);
            for( int i = 0; i < retry; i++ )
            {
                System.out.println("Try to offer: " + (currPrice + step));
                client.setBid(currPrice+step);
                System.out.println("Offert sent");
                currPrice = client.getCurrentBid();                
            }
        }catch(Exception e)
        {
            System.err.println("Error"+ e.getMessage());
            e.printStackTrace();
        }
    }
}
